<template>
  <div>
    <input type="text" v-model="user.account" ><br>
    <input type="text" v-model="user.pwd" ><br>
    <button @click="login()">登录</button><br>
  </div>
</template>

<script>

export default {
  name: "login",
  data(){
    return{
      user:{
        account:'',
        pwd:''
      }
    }
  },
  methods:{
    login:function () {
      this.axios.post(this.baseUrl+"user/login",this.user)
      .then(res =>{
        this.$store.commit('setGrades',res.data.data);
        let redirect = decodeURIComponent(this.$route.query.redirect || '/');  //获取登录成功后要跳转的路由。
        console.log(this.$route.query.redirect);
        this.$router.push({
          path: redirect
        })
      })
    }
  }
}
</script>

<style scoped>

</style>










